// 新建用户 
  // mixNick: mixNick,
  //     nickName: data.nickName,
  //     avatar: data.avatar
exports.createOne = async (params, cloud) => {
	try {
		//先判断是否存在当前主用户id
		let sql =`INSERT INTO user (gmt_create,gmt_modified,mixNick,nickName,avatar) VALUES(now(),now(),'${params.mixNick}','${params.nickName}','${params.avatar}');`
		let data = await cloudfn(cloud, sql);
			console.log("000000000000000000000",data)
		return data;
	} catch (err) {
		return err;
	}
}

/**
 * 查询用户信息
 */
exports.findCountByMixnick  = async (mixNick, cloud) => {
	try {
 		let sql = `select count(1) as count from user where mixNick = '${mixNick}'`;
		let data = await cloudfn(cloud, sql);
		console.log("000000000000000000000",data[0])
		return data[0].count;
	} catch (err) {
		return err;
	}

};









// 埋点
exports.addUserStat = async (params, time, cloud) => {
	try {
		console.log("==============try==================")
		let query = `insert into tracking_message_record (data, gmt_create, gmt_modified) VALUES ('${params}', '${time}', now())`;
		let data = await cloudfn(cloud, query);
		return data;
	} catch (err) {
		console.log("==============err==================", err)
		return err;
	}
},

	cloudfn = async (cloud, sql) => {
		console.log("==============sql==================", sql)
		let cbData = await cloud.dataspace.executeSql(sql, [])
		console.log("==============cbData==================", cbData)
		return cbData
	}




